import java.util.Comparator;
import java.util.Objects;

class Money implements Cloneable{
    public int m ;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

class Person implements Cloneable{
    Money money = new Money();

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Person tmp = (Person) super.clone();
        tmp.money = (Money) this.money.clone();
        return tmp;
    }
}

public class Test1 {
    public static void main(String[] args) throws CloneNotSupportedException {
        Person person1 = new Person();
        Person person2 = (Person) person1.clone();

        person2.money.m = 19;

        System.out.println(person1.money.m);
        System.out.println(person2.money.m);
    }

    public static class NameComparator implements Comparator<classroom> {
        @Override
        public int compare(classroom o1, classroom o2) {
            return o1.getName().compareTo(o2.getName());
        }
    }

    static class classroom implements  Comparable<classroom>{
        private int age;
        private String name;

        public classroom(int age, String name) {
            this.age = age;
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        @Override
        public String toString() {
            return "Test1.classroom{" +
                    "age=" + age +
                    ", name='" + name + '\'' +
                    '}';
        }

        @Override
        public boolean equals(Object o) {
            if (this == o)
                return true;

            if (o == null || getClass() != o.getClass())
                return false;

            classroom classroom = (classroom) o;
            return age == classroom.age && Objects.equals(name, classroom.name);
        }

        @Override
        public int hashCode() {
            return Objects.hash(age, name);
        }

        @Override
        public int compareTo(classroom o) {
            return this.age - o.age;
        }
    }

    public static class AgeComparator implements Comparator<classroom> {
        @Override
        public int compare(classroom o1, classroom o2) {
            return o1.getAge() - o2.getAge();
        }
    }
}
